package com.yixin.hospital.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yixin.hospital.common.ApiResult;
import com.yixin.hospital.entity.domain.DrugTag;
import com.yixin.hospital.entity.dto.req.drugtag.DrugTagAddReqDTO;
import com.yixin.hospital.entity.dto.req.drugtag.DrugTagEditReqDTO;
import com.yixin.hospital.service.DrugTagService;
import com.yixin.hospital.mapper.DrugTagMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author Administrator
* @description 针对表【drug_tag(药品标签表)】的数据库操作Service实现
* @createDate 2024-05-08 14:39:07
*/
@Service
public class DrugTagServiceImpl extends ServiceImpl<DrugTagMapper, DrugTag>
    implements DrugTagService{

    @Resource
    DrugTagService drugTagService;


    @Override
    public ApiResult<?> add(DrugTagAddReqDTO drugTagAddReqDTO, String userName) {
        DrugTag drugTag = new DrugTag();
        BeanUtil.copyProperties(drugTagAddReqDTO, drugTag);
        drugTag.setCreatedBy(userName);
        drugTag.setUpdatedBy(userName);
        drugTagService.save(drugTag);
        return ApiResult.success();
    }

    @Override
    public ApiResult<?> edit(DrugTagEditReqDTO drugTagEditReqDTO, String userName) {
        DrugTag drugTag = new DrugTag();
        BeanUtil.copyProperties(drugTagEditReqDTO, drugTag);
        drugTag.setUpdatedBy(userName);
        drugTagService.updateById(drugTag);
        return ApiResult.success();
    }
}




